<template>
	<Echart :options="options" height="480px" width="100%" />
</template>

<script>
import Echart from '../../components/echart';

export default {
    components: {
        Echart,
    },
    props: {
        cdata: { type: Array, default: () => [] },
    },
    data() {
        return {
            options: {
                legend: {
                },
                dataset: {
                    dimensions: ['time', 'okCount', 'ngCount'],
                    source: [],
                },
                xAxis: {
                    type: 'category',
                    axisLabel: { rotate: -30 },
                },
                yAxis: {},
                series: [
                    {
                        type: 'bar',
                        stack: 'one',
                        label: {
                            show: true,
                            position: 'inside'
                        },
                    }, {
                        type: 'bar',
                        stack: 'one',
                        label: {
                            show: true,
                            position: 'inside'
                        },
                    }
                ]
            },
        };
    },
    watch: {
        cdata: {
            handler(newData) {
                this.options.dataset.source = newData;
            }
        }
    },
}
</script>
